import os
from langchain_community.chat_models import QianfanChatEndpoint
from langchain_core.messages import HumanMessage

os.environ["QIANFAN_AK"] = "7ZITkqmufR2g6MSLQUqsYAXB"
os.environ["QIANFAN_SK"] = "n2YLOoakGri5LfsK8Fxsax86tdeLEfpm"

chat = QianfanChatEndpoint(streaming=True)
res = chat.stream([HumanMessage(content="讲一个故事")])
for chunk in res:
    print(chunk)